package com.software.levelupandroid.loginAndRegistration.presenter;

import android.content.Context;

import com.software.levelupandroid.loginAndRegistration.IView;
import com.software.levelupandroid.loginAndRegistration.model.CallBack;
import com.software.levelupandroid.loginAndRegistration.model.IModel;
import com.software.levelupandroid.loginAndRegistration.model.MainModel;
import com.software.levelupandroid.entity.User;

/**
 * @Description TODO
 * @Author LiangYaJie
 * @CreateTime 2024年04月22日 17:24:08
 */
public class MainPresenter implements IPresenter, CallBack {
    private IModel mainModel;
    private IView mainView;

    public MainPresenter(IView mainView, Context context) {
       mainModel = new MainModel(context);
       this.mainView = mainView;
    }

    @Override
    public void login(String email, String password) {
        mainView.showProgress();
        mainModel.login(email, password,this);
    }

    @Override
    public void onSuccess(User user) {
        mainView.hideProgress();
        mainView.loginSuccess(user);
    }

    @Override
    public void onFailure(String msg) {
        mainView.hideProgress();
        mainView.loginFailure(msg);
    }
}
